package com.acme.iolab.serialization.serializers;

import com.google.gson.Gson;

public class JsonSerializer implements Serializer {

    Gson gson = new Gson();
    private Class clazz;

    public JsonSerializer(Class clazz) {
        this.clazz = clazz;
    }

    @Override
    public Object serialize(Object object) {
        return gson.toJson(object);
    }

    @Override
    public Object deSerialize(Object object) {
        return gson.fromJson((String) object, clazz);
    }
}
